﻿using FunctionScope.Binding;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.Text;
using System.Threading.Tasks;

namespace FunctionScope.Models
{
    /// <summary>
    /// Represents an object that can be sampled in time. The underlying function has a min and max range in the double domain.
    /// </summary>
    public interface ISampleable
    {
        double Sample(double t);
        double Min { get; }
        double Max { get; }
    }

    [DataContract(Name = "BaseFunctionModel", Namespace = "wpfscope.codeplex.com")]
    public class BaseFunctionModel : BindableObject, ISampleable
    {

        #region Lifetime
        public BaseFunctionModel() { }


        public BaseFunctionModel(BaseFunctionModel original)
        {
            Copy(original);
        }

        public virtual BaseFunctionModel Clone()
        {
            return new BaseFunctionModel(this);
        }

        public virtual void Copy(BaseFunctionModel target)
        {
            Name = target.Name;
        }
        #endregion

        private string _name;

        [DataMember]
        public string Name
        {
            get { return _name; }
            set
            {
                _name = value;
                RaisePropertyChanged("Name");
            }
        }

        public virtual double Sample(double t) { return 0; }
        public virtual double Min { get { return double.MinValue; } }
        public virtual double Max { get { return double.MaxValue; } }



    }

}
